package com.battery;

import com.battery.pojo.Order;
import com.battery.service.OrderService;
import com.battery.service.impl.OrderServiceImpl;
import com.battery.util.SpringUtil;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;

import java.sql.Timestamp;

@SpringBootTest
public class Ordertest {

    private OrderServiceImpl ord;

    @Test
    public void ServiceTest() {
        ApplicationContext ctx = SpringUtil.getApplicationContext();
        System.out.println(ctx);
        Timestamp stamp = Timestamp.valueOf("2020-12-20 21:23:58");
        OrderService orderService = (OrderService) ctx.getBean("orderServiceImpl");
        Order Order = new Order(4,stamp,stamp,"aa",3,"aa",2,30,3,stamp,stamp,1);
        Order Order1 = new Order(4,stamp,stamp,"已经修改",3,"aa",2,30,3,stamp,stamp,1);
        System.out.println(orderService.addOrder(Order));
        System.out.println(orderService.modifyOrder(Order1));
        System.out.println(orderService.queryAllOrder());
        System.out.println(orderService.queryAllMerOrder(1));
        System.out.println(orderService.queryAllUserOrder(1));

    }
    @Test
    public void priceTest(){
        Timestamp stamp = Timestamp.valueOf("2021-4-29 20:23:58");
        ApplicationContext ctx = SpringUtil.getApplicationContext();
        System.out.println(ctx);
        OrderService orderService = (OrderService) ctx.getBean("orderServiceImpl");
        Order oo = orderService.calculatedOrder(1,stamp);
        System.out.println(oo);
    }
}
